package com.cloudwise.listener;

import org.springframework.context.support.ClassPathXmlApplicationContext;

import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;

/**
 * @author ：Teacher陈（86521760@qq.com）
 * @date ：Created in 2021/11/18 11:11
 * @description：我的spring容器监听器
 * 在servlet容器初始化的时候，加入spring容器
 * @modified By：
 * @version: 1.0
 */
//@WebListener
/*public class SpringContextListner  implements ServletContextListener {
    @Override
    public void contextInitialized(ServletContextEvent sce) {
        System.out.println("servlet容器开始初始化啦");
        //获取servlet容器
        ServletContext servletContext = sce.getServletContext();
        //创建spring容器
        ClassPathXmlApplicationContext applicationContext= new ClassPathXmlApplicationContext("applicationContext.xml");
        //将spring容器放入servlet容器
        servletContext.setAttribute("applicationContext",applicationContext);
    }
}*/
